using UnityEngine;

namespace ZYFramework.AudioSystem
{
    /// <summary>
    /// 音效播放参数
    /// </summary>
    public struct AudioPlayParams
    {
        /// <summary>
        /// 音量（0-1，默认1）
        /// </summary>
        public float Volume;

        /// <summary>
        /// 音调（0.5-2，默认1）
        /// </summary>
        public float Pitch;

        /// <summary>
        /// 是否循环（默认false）
        /// </summary>
        public bool Loop;

        /// <summary>
        /// 优先级（默认Normal）
        /// </summary>
        public AudioPriority Priority;

        /// <summary>
        /// 空间混合度（0=2D，1=3D，默认0）
        /// </summary>
        public float SpatialBlend;

        /// <summary>
        /// 3D最小衰减距离（默认1）
        /// </summary>
        public float MinDistance;

        /// <summary>
        /// 3D最大衰减距离（默认10）
        /// </summary>
        public float MaxDistance;

        /// <summary>
        /// 默认参数实例
        /// </summary>
        public static AudioPlayParams Default => new AudioPlayParams
        {
            Volume = 1f,
            Pitch = 1f,
            Loop = false,
            Priority = AudioPriority.Normal,
            SpatialBlend = 0f,
            MinDistance = 1f,
            MaxDistance = 10f
        };

        /// <summary>
        /// 创建2D音效参数
        /// </summary>
        /// <param name="volume">音量</param>
        /// <param name="pitch">音调</param>
        /// <param name="loop">是否循环</param>
        /// <param name="priority">优先级</param>
        /// <returns>播放参数</returns>
        public static AudioPlayParams Create2D(float volume = 1f, float pitch = 1f, bool loop = false, AudioPriority priority = AudioPriority.Normal)
        {
            return new AudioPlayParams
            {
                Volume = volume,
                Pitch = pitch,
                Loop = loop,
                Priority = priority,
                SpatialBlend = 0f,
                MinDistance = 1f,
                MaxDistance = 10f
            };
        }

        /// <summary>
        /// 创建3D音效参数
        /// </summary>
        /// <param name="volume">音量</param>
        /// <param name="pitch">音调</param>
        /// <param name="loop">是否循环</param>
        /// <param name="priority">优先级</param>
        /// <param name="minDistance">最小衰减距离</param>
        /// <param name="maxDistance">最大衰减距离</param>
        /// <returns>播放参数</returns>
        public static AudioPlayParams Create3D(float volume = 1f, float pitch = 1f, bool loop = false, AudioPriority priority = AudioPriority.Normal, float minDistance = 1f, float maxDistance = 10f)
        {
            return new AudioPlayParams
            {
                Volume = volume,
                Pitch = pitch,
                Loop = loop,
                Priority = priority,
                SpatialBlend = 1f,
                MinDistance = minDistance,
                MaxDistance = maxDistance
            };
        }
    }
}
